// pages/mycoupons/mycoupons.js
var app= getApp();//引用app.js
Page({
  data:{
    "fromPage":"buy",//根据上页传入的数据判断立即使用按钮跳转页面还是弹出提示  
    "currentNavtab":0,
    "navTab":["未使用","已使用","已过期"],
    "coupons0":[
        {
            price:"0.01",
            endTime:"2017-03-03 23:59:59"
        },
        {
            price:"0.01",
            endTime:"2017-03-03 23:59:59"
        },
        {
            price:"0.01",
            endTime:"2017-03-03 23:59:59"
        }
    ],
    "coupons1":[
        {
            price:"0.01",
            endTime:"2017-03-03 23:59:59"
        },
        {
            price:"0.01",
            endTime:"2017-03-03 23:59:59"
        },
        {
            price:"0.01",
            endTime:"2017-03-03 23:59:59"
        }
    ],
    "coupons2":[
        {
            price:"0.01",
            endTime:"2017-03-03 23:59:59"
        },
        {
            price:"0.01",
            endTime:"2017-03-03 23:59:59"
        },
        {
            price:"0.01",
            endTime:"2017-03-03 23:59:59"
        }
    ],
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
    // wx.setNavigationBarTitle({title: '我的优惠券'})//当前页面的标题
    this.setData({
      fromPage: options.page
    });
  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  },
  switchTab: function(e){
      //顶部导航菜单
    this.setData({
      currentNavtab: e.currentTarget.dataset.idx
    });
  },
  btnUse:function(e){
    if(this.data.fromPage=="user"){
        wx.showToast({
            title: '请在支付时使用',
            icon: 'loading',
            duration: 1500
        })
    }else if(this.data.fromPage=="buy"){
        wx.redirectTo({
          url: '../index_buy/index_buy?'
        })
    }
  },
  btnUsed:function(e){
    wx.showToast({
        title: '此券已被使用',
        icon: 'loading',
        duration: 1000
    })
  },
  btnPass:function(e){
    wx.showToast({
        title: '此券已过期',
        icon: 'loading',
        duration: 1000
    })
  }
})